home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / cmprss.exe / COMPRESS.CLS < prev    next >
Text File  |  1993-01-26  |  2KB  |  57 lines

  1. #ifndef COMPRESS_CLS
  2. #define COMPRESS_CLS
  3.  
  4. #include <fstream.h>
  5. #include "const.h"
  6. #include "type.h"
  7.  
  8. class cpofstream : public ofstream
  9.     {
  10.     public:
  11.  
  12.         cpofstream(void);
  13.         cpofstream(char *fn);
  14.         ~cpofstream();
  15.  
  16.         cpofstream& operator<< (char c)        {fillbuf(&c,sizeof(char)); return *this;};
  17.         cpofstream& operator<< (short s)        {fillbuf(&s,sizeof(short)); return *this;};
  18.         cpofstream& operator<< (int i)        {fillbuf(&i,sizeof(int)); return *this;};
  19.         cpofstream& operator<< (long l)        {fillbuf(&l,sizeof(long)); return *this;};
  20.         cpofstream& operator<< (float f)        {fillbuf(&f,sizeof(float)); return *this;};
  21.         cpofstream& operator<< (double d)        {fillbuf(&d,sizeof(double)); return *this;};
  22.         cpofstream& operator<< (long double ld)    {fillbuf(&ld,sizeof(long double)); return *this;};
  23.         cpofstream& operator<< (char *s);
  24.         cpofstream& operator<< (void* v);
  25.  
  26.         cpofstream& put(char c)                         {fillbuf(&c,sizeof(char)); return *this;};
  27.         cpofstream& write(signed char* s, int n)    {fillbuf(s,n); return *this;};
  28.         cpofstream& write(unsigned char* s, int n)    {fillbuf(s,n); return *this;};
  29.  
  30.         void open(char *fn);
  31.         filebuf* close(void);
  32.         cpofstream& flush(void);
  33.  
  34. // The following functions are defined so that they are NO OP's:
  35.  
  36.         cpofstream& seekp(long) {return *this;};
  37.         cpofstream& seekp(long, seek_dir) {return *this;};
  38.  
  39. // ---
  40.  
  41.     private:
  42.  
  43.         void init(void);
  44.         void reset(void);
  45.         void clear(void);
  46.         void encode(void);
  47.         void fillbuf(void* v, int l);
  48.         int compress(uchar *inbuff, uint inbuff_len, uchar *outbuff, uchar *hash_tbl[], uint hash_len);
  49.  
  50.         uchar *inbuf;                // input buffer
  51.         uchar *outbuf;                // output buffer after compression
  52.         uchar **hash_table;            // hash table
  53.         int idx;                    // input buffer index
  54.     };
  55.  
  56. #endif
  57.